test: optimize and de-brittle test suite - #100
Conversation
📝 WalkthroughWalkthroughThe pull request applies formatting and typing cleanup, updates timezone-aware parsing and conversions, simplifies status returns, and consolidates tests through parametrization and direct mocks. ChangesLibrary behavior and tooling
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Documentation build overview
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/source/conf.py`:
- Line 24: Keep the Sphinx configuration key named copyright in the
configuration assignment, and add a targeted Ruff A001 suppression for that line
rather than renaming the key.
In `@tests/test_client_endpoint.py`:
- Around line 974-999: The boolean parameters expected_use_snake_case in
tests/test_client_endpoint.py:974-999 and expected in tests/test_dhcp.py:295-314
trigger Ruff FBT001; update both test parameter definitions to follow the
repository’s existing style by making them keyword-only, or add a justified
local # noqa: FBT001 suppression where that style requires positional
parameters.
In `@tests/test_scripts_aiopnsense_dump.py`:
- Around line 972-973: Add Google Style docstrings to both nested raise_error
helpers: tests/test_scripts_aiopnsense_dump.py lines 972-973 and
tests/test_scripts_opnsense_api_call.py lines 836-837. Document that each helper
raises the parameterized CLI failure created by error_factory(module).
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3bdee3eb-3ca3-435e-98ec-a1751b1dd692
📒 Files selected for processing (32)
aiopnsense/__init__.pyaiopnsense/client.pyaiopnsense/client_transport.pyaiopnsense/dhcp.pyaiopnsense/firewall.pyaiopnsense/nut.pyaiopnsense/system.pyaiopnsense/traffic.pyaiopnsense/vnstat.pydocs/source/_ext/opnsense_client_api.pydocs/source/conf.pyscripts/_opnsense_live_common.pyscripts/aiopnsense_dump.pyscripts/opnsense_api_call.pytests/conftest.pytests/test_client_base.pytests/test_client_endpoint.pytests/test_client_queue.pytests/test_client_transport.pytests/test_dhcp.pytests/test_exceptions.pytests/test_firewall.pytests/test_helpers.pytests/test_nut.pytests/test_scripts_aiopnsense_dump.pytests/test_scripts_live_common.pytests/test_scripts_opnsense_api_call.pytests/test_smart.pytests/test_speedtest.pytests/test_system.pytests/test_traffic.pytests/test_vnstat.py
Summary
Streamlines the test suite by combining behaviorally equivalent cases and removing assertions coupled to internal implementation details.
What Changed
Why
The suite now focuses on observable behavior, reducing maintenance churn from harmless refactors while retaining regression coverage.
Summary by CodeRabbit
Bug Fixes
Refactor
Tests
Greptile Summary
The PR consolidates repetitive tests, removes assertions coupled to implementation details, and applies behavior-preserving cleanup across the client and scripts.
Confidence Score: 4/5
The PR is not yet safe to merge because the outstanding delayed-import issue causes the configured Ruff check to fail.
The two live scripts still place imports after executable module statements without E402 suppressions, while the repository’s Ruff configuration provides no applicable exclusion or per-file ignore.
Files Needing Attention: scripts/aiopnsense_dump.py and scripts/opnsense_api_call.py
Important Files Changed
aiohttpimport unsuppressed after executable module code, sharing the outstanding Ruff failure.removeprefixbehavior.Reviews (3): Last reviewed commit: "test: document parameterized CLI error h..." | Re-trigger Greptile